package java_DesignPattern.BehavioralPattern.VisitorPattern;

/**
 * 访问者模式---测试类
 */
public class Test {

    public static void main(String[] args) {
        // 创建具体元素
        Cat cat = new Cat();
        Dog dog = new Dog();

        // 添加具体元素到对象结构
        Home home = new Home();
        home.addAnimal(cat);
        home.addAnimal(dog);

        // 创建访问者
        Person owner = new Owner();
        Person someone = new Someone();

         // 访问者访问具体元素
        home.action(owner);
        home.action(someone);
    }
}
